package com.zsj.hello.three;

import com.rabbitmq.client.Channel;
import com.zsj.hello.util.BaseUtil;
import com.zsj.hello.util.RabbimqFactoryUtil;

import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * @author https://gitee.com/zhengshengjun
 * @date 2023/8/29.
 */
public class Producer {

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel
                = RabbimqFactoryUtil.getRabbitMQChannel();

        channel.queueDeclare(BaseUtil.QUEUE_NAME, true, false, false, new HashMap<>());
        //开始发送消息
        System.out.println("开始发送消息~");
        while(true){
            Scanner scanner = new Scanner(System.in);
            channel.basicPublish("", BaseUtil.QUEUE_NAME, null, scanner.next().getBytes());
            System.out.println("发送成功");
        }
    }
}
